<template>
	<view class="container">
		<view style="margin: 0 5px 0 5px;">
			<view v-for="item,index in historyList" :key="index" @click="itemClick(item.vod_id)"
				style="display: flex;flex-direction: row;margin-top: 10px; border: 1px solid #ffce45;width: 100%;height: 160px;border-radius: 10px;">
				<view class="img" style="margin: 5px 5px 10px 10px;">
					<image @click="imgClick(item.vodId,item.anthology-1)" style="height: 150px;width: 110px;border-radius: 6px;object-fit: cover;"
						:src="item.vodPicUrl">
					</image>
				</view>
				<view class="introduce"
					style="width: 100%;display: flex;flex-direction: column;margin: 5px 5px 10px 10px;">
					<text
						style="font-size: 17px;font-weight: bold; width: 200px;">{{item.vodName}}</text>
					<view style="margin-top: 15px;display: flex;flex-direction: row;">
						<text>第{{item.anthology}}集</text>
					</view>
					<text
						style="display:inline-block; word-wrap: break-word;margin-top: 15px;color: #76797d;font-size: 10px;height: 40px; width: 200px;overflow: hidden;text-overflow: ellipsis;">
						{{item.vod_blurb}}
					</text>
					<view
						style="margin:10px 0px 0px 0px;font-size: 10px;color: #76797d;width: auto;height: 19px;border-radius: 5px;background-color: #e8edf3;text-align: center;">
						<text>{{item.historyTime}}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getHistory
	} from '@/config/api.js'
	export default {
		data() {
			return {
				userId: '',
				historyList: []
			}
		},
		onLoad() {
			//获取用户账户
			if (getApp().globalData.isLogin) {
				try {
					var res = uni.getStorageSync('user')
					if (res) {
						this.userId = res.userId
					}
				} catch (e) {
					// error
					console.log(e)
				}
			}
		},
		onShow() {
			this.init();
		},
		methods: {
			init() {
				getHistory({
					params: {
						userId: this.userId
					}
				}).then(res => {
					this.historyList = res.data.data;
					console.log(this.historyList)
				}).catch(err => {
					console.log(err)
				})
			},
			//点击音频事件
			imgClick(vodId,anthology) {
				uni.navigateTo({
					url: '/pages/video/video?vodId=' + vodId+'&anthology='+anthology
				})
			}
		}
	}
</script>

<style>

</style>